using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Client;

namespace BuildStatusIndicator.Controller.TfsConnectionStatergy
{
    public abstract class ConnectinonStatergyBase : IConnectinonStratergy
    {
        private readonly uint _pollingIntervall;
        private readonly string _serverUrl;
        private readonly string _teamProject;

        protected ConnectinonStatergyBase(string serverUrl, string teamProject, uint pollingIntervall)
        {
            _serverUrl = serverUrl;
            _teamProject = teamProject;
            _pollingIntervall = pollingIntervall;
        }

        #region IConnectinonStratergy Members

        public string ServerUrl
        {
            get { return _serverUrl; }
        }

        public string TeamProject
        {
            get { return _teamProject; }
        }

        public uint PollingIntervall
        {
            get { return _pollingIntervall; }
        }

        public IBuildServer GetBuildServer()
        {
            return (IBuildServer) Connect().GetService(typeof (IBuildServer));
        }

        #endregion

        protected abstract TeamFoundationServer Connect();
    }
}